import React from 'react';
import { Route, Redirect } from 'react-router-dom'
import { isAuth } from 'utils/token'

export default function AuthRoute({ component: Component, ...test }) {
    return <Route {...test} render={props => {
        console.log(props,"111111")
        if (isAuth()) {
            return <Component {...props} />
        } else {
            return <Redirect to={{ pathname: "/login", state: { toPath: props.location.pathname } }} />
        }
    }} />
}